package com.zzptc.zzsgz.bdsjws.fragments;


import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.activities.InsertLianXiRenActivity;
import com.zzptc.zzsgz.bdsjws.adapter.ContactAdater;
import com.zzptc.zzsgz.bdsjws.fragments.base.BaseFragmentbase;
import com.zzptc.zzsgz.bdsjws.vo.Contact;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


/**
 * Created by Administrator on 2017/6/9 009 .
 */

public class SelectContactFragment extends BaseFragmentbase {
    @BindView(R.id.rv_select_contact)
    RecyclerView rvSelectContact;
List<Contact>contactList=new ArrayList<Contact>();
    ContactAdater contactAdater;
    @Override
    public int getXML() {
        return R.layout.select_contact_fragment;
    }

    @Override
    public void initView() {
//项 适配器 可共用
        // List<Contact>anyList=new ArrayList<Contact>();
        // List<Contact>allList= MyApplication.getList();
        // if (getActivity()instanceof InsertLianXiRenActivity)
        // for (int i=0;i<allList.size();i++){
        //  ((InsertLianXiRenActivity)getActivity())
        // }
        //ContactAdater contactAdater=new ContactAdater();
        // rvSelectContact.setLayoutManager(new LinearLayoutManager(getActivity()));
    }

    @Override
    public void initDate() {
        rvSelectContact.setLayoutManager(new LinearLayoutManager(MyApplication.getContext()));
        contactAdater=new ContactAdater(contactList);
        rvSelectContact.setAdapter(contactAdater);
    }

    public void getSelectContactList(List<Contact> contacts) {
        contactList.clear();
         contactList.addAll(contacts);
        if(contactAdater!=null) {
            contactAdater.notifyDataSetChanged();
        }
    }
}